package com.unidt.www.module.bpm.utils;

public class FlowUtils {

    public static boolean containsEl(String v1Key,String v1Value,String els) {
        String el=els.replace("${","");
        el=el.replace("}","").trim();
      if(el.contains("==")){
          String elsValue=el.replace(v1Key+"==","");
          if(v1Value.equals(elsValue)){
              return true;
          }
      }else if(el.contains(">")){
          String elsValue=el.replace(v1Key+">","");
          try {
              if(Integer.valueOf(v1Value)>Integer.valueOf(elsValue)){
                  return true;
              }
          }catch (Exception e){
              return false;
          }

      }else if(el.contains(">=")){
          String elsValue=el.replace(v1Key+">=","");
          try {
              if(Integer.valueOf(v1Value)>=Integer.valueOf(elsValue)){
                  return true;
              }
          }catch (Exception e){
              return false;
          }

      }else if(el.contains("<")){
          String elsValue=el.replace(v1Key+"<","");
          try {
              if(Integer.valueOf(v1Value)<Integer.valueOf(elsValue)){
                  return true;
              }
          }catch (Exception e){
              return false;
          }

      }else if(el.contains("<=")){
          String elsValue=el.replace(v1Key+"<=","");
          try {
              if(Integer.valueOf(v1Value)<=Integer.valueOf(elsValue)){
                  return true;
              }
          }catch (Exception e){
              return false;
          }
      }else if(el.contains("!=")){
          String elsValue=el.replace(v1Key+"!=","");
          try {
              if(Integer.valueOf(v1Value).equals(Integer.valueOf(elsValue))){
                  return true;
              }
          }catch (Exception e){
              return false;
          }
      }else if(el.contains("containsAny")){
          String elsValue=el.replace(  "var:containsAny("+v1Key+",","");
          String elsValue2=elsValue.replace(  ")","");
          String elsValue3=elsValue2.replace("\"", "");
          String elsValue4=elsValue3.replace(" ", "");

          try {
              if(v1Value.contains(elsValue4)){
                  return true;
              }
          }catch (Exception e){
              return false;
          }
      }
        return false;
    }
}
